def dec2bin(dec):
    strOut = ""
    while dec > 0:
        strOut = str(dec % 2) + strOut
        dec = dec /2
    return strOut

def bin2dec(bin):
    strOut = 0
    index = 0
    for i in bin:
        if int(i) == 1:
           strOut += 2**int(index)
        index += 1
    return strOut

def main():
    print bin2dec("1001001001")
    print dec2bin(585)

if __name__ == "__main__":
    main()